

const fp = require("lodash/fp");

const cars = [
  {
    name: "Frmsn FF",
    horsepower: 6601,
    dollar_value: 700006,
    in_stock: true,
  },
  {
    name: "Trds TT",
    horsepower: 6602,
    dollar_value: 700007,
    in_stock: false,
  },
  {
    name: "Jerson JJ",
    horsepower: 6603,
    dollar_value: 700008,
    in_stock: false,
  },
  {
    name: "Adius AA",
    horsepower: 6604,
    dollar_value: 700009,
    in_stock: true,
  },
  {
    name: "BigBug BB",
    horsepower: 6605,
    dollar_value: 7000010,
    in_stock: true,
  },
];

const _underscore = fp.replace(/\W+/g,"_")
const sanitizeNames = fp.flowRight(_underscore,fp.toLower);
cars.forEach(item=>{
  Object.assign(item,{name:sanitizeNames(item.name)})
})
console.log('cars: ', cars);


